package com.gsm.service.impl;

import com.gsm.entity.SubjectDetails;
import com.gsm.dao.SubjectDetailsDao;
import com.gsm.service.SubjectDetailsService;
import com.gsm.entity.Result;
import com.gsm.utils.IdUtils;
import com.gsm.entity.StatusCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 科目介绍(SubjectDetails)表服务实现类
 */
@Service
public class SubjectDetailsServiceImpl implements SubjectDetailsService {
    @Autowired
    private SubjectDetailsDao subjectDetailsDao;
    @Autowired
    private IdUtils idUtils;
    
    
    @Override
    public Result insertSubjectDetails(SubjectDetails subjectDetails) {
        long subjectDetailsId = idUtils.nextId();
        subjectDetails.setSubjectDetailsId(subjectDetailsId);
        subjectDetailsDao.insertSubjectDetails(subjectDetails);
        Result result = new Result(true,StatusCode.OK);
        return result;
    }
    
    /**
     * 根据 主键 subjectDetailsId 删除
     * @param subjectDetailsId 主键
     * @return
     */
    @Override
    public Result deleteSubjectDetailsBySubjectDetailsId(Long subjectDetailsId) {
        subjectDetailsDao.deleteSubjectDetailsBySubjectDetailsId(subjectDetailsId);
        Result result = new Result(true, StatusCode.OK);
        return result;
    }
    
    /**
     * 修改
     * @param subjectDetails 实例对象
     * @return
     */
    @Override
    public Result updateSubjectDetailsBySubjectDetailsId(SubjectDetails subjectDetails) {
        subjectDetailsDao.updateSubjectDetailsBySubjectDetailsId(subjectDetails);
        Result result = new Result(true, StatusCode.OK);
        return result;
    }
    
    /**
     * 根据 id 查询单条数据
     * @param subjectDetailsId 主键
     * @return
     */
    @Override
    public Result selectSubjectDetailsBySubjectDetailsId(Long subjectDetailsId) {
        SubjectDetails subjectDetails = subjectDetailsDao.selectSubjectDetailsBySubjectDetailsId(subjectDetailsId);
        Result result = new Result(true, StatusCode.OK,"",subjectDetails);
        return result;
    }

    @Override
    public Result selectSubjectDetailsBySubjectId(Long subjectId) {
        SubjectDetails subjectDetails = subjectDetailsDao.selectSubjectDetailsBySubjectId(subjectId);
        Result result = new Result(true, StatusCode.OK,"",subjectDetails);
        return result;
    }

    /**
     * 根据条件查询列表
     * @param subjectDetails 实例对象
     * @return
     */
    @Override
    public Result selectSubjectDetailsList(SubjectDetails subjectDetails) {
        List<SubjectDetails> list = subjectDetailsDao.selectSubjectDetailsList(subjectDetails);
        Result result = new Result(true, StatusCode.OK,"",list);
        return result;
    }

}